home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 11.2 KB | 355 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrawPart.h
- // Release Version: $ 1.0d11 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef DRAWPART_H
- #define DRAWPART_H
-
- // ----- Part Layer -----
-
- #ifndef FWPARTNG_H
- #include "FWPartng.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #ifndef FWBWPAT_H
- #include "FWBWPat.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRESFIL_H
- #include "FWResFil.h"
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma import on
- #endif
-
- class FW_CLASS_ATTR FW_CFloatingWindow;
- class FW_CLASS_ATTR FW_CMenuEvent;
- class FW_CLASS_ATTR FW_CDropCommand;
- class FW_CLASS_ATTR FW_CPresentation;
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma import off
- #endif
-
- class FW_CLASS_ATTR CBaseShape;
- class FW_CLASS_ATTR CProxyShape;
- class FW_CLASS_ATTR CToolFrame;
- class FW_CLASS_ATTR CPaletteFrame;
- class FW_CLASS_ATTR CPatternFrame;
- class FW_CLASS_ATTR CDrawSelection;
- class FW_CLASS_ATTR FW_CGraphicContext;
- class FW_CLASS_ATTR CDrawLinkManager;
-
- //========================================================================================
- // Defines
- //========================================================================================
-
- #define kContentAnnotationProp "Apple:Framework:Proposition:ContentAnnotation"
- #define kContentAnnotationValue "Apple:Framework:Value:ContentAnnotation"
-
- //========================================================================================
- // class CDrawPart
- //========================================================================================
-
- class FW_CLASS_ATTR CDrawPart : public FW_CEmbeddingPart
- {
- public:
- static const ODValueType kPartKind;
- static const ODValueType kPartUserName;
-
- friend class CDrawLinkManager;
-
- //----------------------------------------------------------------------------------------
- // Initialization/Destruction
- //
- public:
- CDrawPart(ODPart* odPart);
- virtual ~ CDrawPart();
-
- virtual void Initialize(Environment *ev);
- void InitializeMenuBar(Environment* ev, FW_CMenuBar* menuBar);
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- virtual FW_CFrame* NewFrame(Environment *ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage);
-
- virtual void ExternalizeContent(Environment *ev,
- ODStorageUnit* storageUnit,
- FW_CCloneInfo* cloneInfo);
- virtual void InternalizeContent(Environment *ev,
- ODStorageUnit* storageUnit,
- FW_CCloneInfo* cloneInfo);
-
- virtual FW_Boolean DoMenu(Environment *ev, const FW_CMenuEvent& theMenuEvent);
- virtual FW_Boolean DoAdjustMenus(Environment *ev, FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus, FW_Boolean isRoot);
-
- virtual FW_CLinkManager* NewLinkManager(Environment *ev);
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- void RemoveShape(Environment* ev, CBaseShape* shape);
- void AddShape(Environment* ev, CBaseShape* shape);
- void DeleteShape(Environment* ev, CBaseShape* shape);
- void AddShapeAfter(Environment* ev, CBaseShape* after, CBaseShape* shape);
-
- CBaseShape* WhichShape(Environment *ev,
- FW_CGraphicContext& gc,
- const FW_CMouseEvent& theMouseEvent,
- FW_Boolean hasToBeSelected) const;
-
- FW_CPrivOrderedCollection* GetShapeList() const;
- FW_CFixed GetPenSize() const;
- unsigned short GetRenderVerb() const;
-
- FW_CPoint GetDrawingSize() const;
-
- void CheckTool(Environment* ev, unsigned short oldTool, unsigned short newTool);
- void CheckRenderVerb(Environment* ev, unsigned short oldRenderVerb, unsigned short newRenderVerb);
- void SetRenderVerb(Environment* ev, unsigned short renderVerb);
-
- void GetFillColor(FW_CColor& color) const;
- void GetFrameColor(FW_CColor& color) const;
-
- void SetFillColor(Environment* ev, const FW_CColor& color);
- void SetFrameColor(Environment* ev, const FW_CColor& color);
-
- FW_PPattern GetFillPattern() const;
- FW_PPattern GetFramePattern() const;
-
- void SetFillPattern(Environment* ev, short newFillPatIndex);
- void SetFramePattern(Environment* ev, short newFramePatIndex);
-
- void MoveForward(Environment *ev);
- void MoveBackward(Environment *ev);
- void MoveToFront(Environment *ev);
- void MoveToBack(Environment *ev);
- void UpdateAfterMove(Environment* ev);
-
- void SetTool(Environment* ev, unsigned short newTool);
- unsigned short GetTool() const;
-
- FW_PPattern GetPattern(short patIndex) const;
-
- void UpdateAllToolFacets(Environment *ev);
-
- FW_CPresentation* GetMainPresentation() const;
- FW_CPresentation* GetPalettePresentation() const;
- FW_CPresentation* GetPatternPresentation() const;
- FW_CPresentation* GetToolPresentation() const;
-
- FW_Boolean IsAutoGridOn() const;
-
- CBaseShape* NewShape(Environment* ev, unsigned short shapeType);
-
- //--- Persistent link support ---
- void DoPostCreate(Environment* ev); // MacApp forever!
- CBaseShape* FindShapeWithIndex(short extIndex);
-
- private:
- FW_CPrivOrderedCollection* ExtractSelection(Environment* ev);
-
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- short fNbEmbedded;
-
- FW_CFloatingWindow* fPaletteWindow;
- FW_CFloatingWindow* fPatternWindow;
- FW_CFloatingWindow* fToolsWindow;
-
- CToolFrame* fToolFrame;
- CPaletteFrame* fPaletteFrame;
- CPatternFrame* fPatternFrame;
-
- FW_CPrivOrderedCollection* fShapeList;
- FW_CPoint fDrawingSize;
-
- unsigned short fTool;
- FW_CFixed fCurrentPenSize;
- unsigned short fRenderVerb;
- FW_CColor fFillColor;
- FW_CColor fFrameColor;
- short fFillPatIndex;
- short fFramePatIndex;
-
- CDrawSelection* fDrawSelection; // Attention I don't own the selection the presentation is
-
- FW_CPresentation* fPalettePresentation;
- FW_CPresentation* fPatternPresentation;
- FW_CPresentation* fToolPresentation;
- FW_CPresentation* fMainPresentation;
- FW_CPresentation* fAlignObjectsPresentation;
-
- FW_PPattern fPatternTable[12];
-
- FW_Boolean fAutoGrid;
-
- ODCommandID fUnit;
- ODCommandID fArcUnit;
-
- FW_Boolean fPostCreated; // perform DoPostCreate only once
- };
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetDrawingSize
- //----------------------------------------------------------------------------------------
- inline FW_CPoint CDrawPart::GetDrawingSize() const
- {
- return fDrawingSize;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::IsAutoGridOn
- //----------------------------------------------------------------------------------------
- inline FW_Boolean CDrawPart::IsAutoGridOn() const
- {
- return fAutoGrid;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetShapeList
- //----------------------------------------------------------------------------------------
- inline FW_CPrivOrderedCollection* CDrawPart::GetShapeList() const
- {
- return fShapeList;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPenSize
- //----------------------------------------------------------------------------------------
- inline FW_CFixed CDrawPart::GetPenSize() const
- {
- return fCurrentPenSize;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetRenderVerb
- //----------------------------------------------------------------------------------------
- inline unsigned short CDrawPart::GetRenderVerb() const
- {
- return fRenderVerb;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetTool
- //----------------------------------------------------------------------------------------
- inline unsigned short CDrawPart::GetTool() const
- {
- return fTool;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetMainPresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetMainPresentation() const
- {
- return fMainPresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPalettePresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetPalettePresentation() const
- {
- return fPalettePresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPatternPresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetPatternPresentation() const
- {
- return fPatternPresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetToolPresentation
- //----------------------------------------------------------------------------------------
- inline FW_CPresentation* CDrawPart::GetToolPresentation() const
- {
- return fToolPresentation;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetPattern
- //----------------------------------------------------------------------------------------
- inline FW_PPattern CDrawPart::GetPattern(short patIndex) const
- {
- FW_ASSERT(patIndex>=0 && patIndex<12);
- return fPatternTable[patIndex];
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFillColor
- //----------------------------------------------------------------------------------------
- inline void CDrawPart::GetFillColor(FW_CColor& color) const
- {
- color = fFillColor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFrameColor
- //----------------------------------------------------------------------------------------
- inline void CDrawPart::GetFrameColor(FW_CColor& color) const
- {
- color = fFrameColor;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFillPattern
- //----------------------------------------------------------------------------------------
- inline FW_PPattern CDrawPart::GetFillPattern() const
- {
- return fPatternTable[fFillPatIndex];
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawPart::GetFramePattern
- //----------------------------------------------------------------------------------------
- inline FW_PPattern CDrawPart::GetFramePattern() const
- {
- return fPatternTable[fFramePatIndex];
- }
-
- #endif
-